package Exercise;

public class Person {
    private String name;
    private int age;

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void keepPet(Animal a, String something) {
//        System.out.println(age + "岁的" + name + "养了只" + a.getAge() + "岁的" + a.getColor() + "色的" + "吃" + something + "的动物");
        if (a instanceof Dog d) {
            System.out.println(age + "岁的" + name + "养了只" + d.getAge() + "岁的" + d.getColor() + "色的" + "吃" + something + "的狗");
            d.look();
        }
        else if(a instanceof Cat c){
            System.out.println(age + "岁的" + name + "养了只" + c.getAge() + "岁的" + c.getColor() + "色的" + "吃" + something + "的猫");
        }
        else{
            System.out.println("无");
        }
    }
}
